MODULE Magic;

IMPORT  SYSTEM, Storage;
IMPORT  MagicSys, MagicAES, MagicStrings;
IMPORT  mtAppl, mtRsc, mtDials, mtAlerts, mtHelp, mtUtils, mtPopups, mtText,
        mtAESMenus, mtTerminal, mtMenus, mtWindows, mtFonts, mtFontselector;

IMPORT  RTD;

CONST   cRes1 =    '[3][Bitte benutzen Sie f�r einen|korrekten Programmablauf|';
        cRes2 =    'mindestens eine Aufl”sung|von 640 x 200 Punkten!][ [Ok ]';
        cTitle =   '[0][%DMagicDemo||Das Demo zu den MagicTools...|(C)92 by Peter Hellinger||';
        cTitle2 =  'Dieses Programm ist Freeware!|][ [Ok ]';
        cAlert1 =  '[0][Es k”nnen bis zu 16 Zeilen und 4 Buttons in einem|';
        cAlert2 =  'Alert dargestellt werden. Auch in der Gr”že des Icon-Images|';
        cAlert3 =  'ist man nicht begrenzt. Jede Alert-Zeile darf bis zu 60|';
        cAlert4 =  'Zeichen aufnehmen. Es k”nnen auch in gewissem Grenzen|';
        cAlert5 =  'Effekte eingesetzt werden:||';
        cAlert6 =  '%D Diese Zeile wird doppelt unterstrichen.||';
        cAlert7 =  '%U Diese Zeile wird einfach unterstrichen.||';
        cAlert8 =  '%F Und diese wird Fett geschrieben][[Toll|[Prima|[Klasse|[Ok]';
        
CONST   Mover    =   1;  (* Formular/Dialog *)
        Moverok  =  14;

CONST   String   =   3;  (* Formular/Dialog *)
        Stringok =   9;

CONST   Buttons1 =   2;  (* Formular/Dialog *)
        Butt1ok =   27;
        Buttons2 =   7;
        Butt2ok =    3;

CONST   Frame    =   4;  (* Formular/Dialog *)
        Frameok  =  12;

CONST   Edit     =   6;  (* Formular/Dialog *)
        Ed2      =   6;
        Ed3      =   7;
        Ed4      =   8;
        Editable =  12;
        Editok   =  13;
        Ed1      =  14;

CONST   Menuline =   9;  (* Menuebaum *)

CONST   Mainmenu =  10;  (* Menuebaum *)
        Magicdem =   3;
        Datei    =   4;
        Dialog   =   5;
        Menus    =   6;
        Sonstige =   7;
        Info     =  10;
        Quit     =  19;
        Moveobjc =  21;
        Stringob =  22;
        Buttonob =  23;
        Frameobj =  24;
        Circleob =  25;
        Editobjc =  26;
        Winmenu  =  28;
        Popupmen =  29;
        Popups   =  30;
        Alertbox =  32;
        Fontsel  =  33;
        Windial  =  34;

CONST   MaxLines = 400;

TYPE    InfoAction = (open, close, redraw, lineup, linedown, pageup, pagedown);

VAR     Rsc:            mtRsc.RESOURCE;
        dial:           SYSTEM.ADDRESS;
        string:         ARRAY [0..512] OF CHAR;
        b, WinOpen:     BOOLEAN;
        Win2Open:       BOOLEAN;
        i, win, win2, win3: INTEGER;
        old, term, term2, term3: mtTerminal.TERMINAL;
        scr, small, rect, bar: mtUtils.tRect;
        Menubar:        mtMenus.MENUBAR;
        Text:           mtText.TEXT;
        pos, zeilen:    INTEGER;


PROCEDURE ShowInfo (action: InfoAction);
VAR i: INTEGER;
    r: mtUtils.tRect;
    l: mtText.LINE;
    z: mtText.PtrString;

 PROCEDURE WriteScreen;
 VAR i: INTEGER;
 BEGIN
  mtTerminal.ClearScreen;
  l:= mtText.FindNumber (Text, LONG (pos));
  FOR i:= 0 TO mtTerminal.Lines - 1 DO
   IF l # mtText.NilLine() THEN
    z:= mtText.GetLinePtr (l);
    mtTerminal.GotoXY (0, i);  mtTerminal.WriteLine (z^);
    l:= mtText.NextLine (l);
   END;
  END;
  pos:= pos + mtTerminal.Lines;
 END WriteScreen;

 PROCEDURE LineUp;
 BEGIN
  IF pos > mtTerminal.Lines THEN
   DEC (pos);
   mtTerminal.GotoXY (0, 0);
   mtTerminal.InsertLine;
   l:= mtText.FindNumber (Text, LONG (pos - mtTerminal.Lines));
   IF l # mtText.NilLine() THEN
    z:= mtText.GetLinePtr (l);  mtTerminal.WriteLine (z^);
   END;
   mtAppl.MouseOn;
  END;
 END LineUp;

 PROCEDURE LineDown;
 BEGIN
  IF pos < zeilen THEN 
   mtTerminal.GotoXY (0, 0);
   mtTerminal.DeleteLine; 
   mtTerminal.GotoXY (0, mtTerminal.Lines);
   INC (pos);
   l:= mtText.FindNumber (Text, LONG (pos));
   IF l # mtText.NilLine() THEN
   z:= mtText.GetLinePtr (l);  mtTerminal.WriteLine (z^);
   END;
   mtAppl.MouseOn;
  END;
 END LineDown;

 PROCEDURE PageUp;
 BEGIN
  DEC (pos, mtTerminal.Lines * 2);
  IF pos < mtTerminal.Lines THEN  pos:= 0;  END;
  WriteScreen;
  mtAppl.MouseOn;
 END PageUp;

 PROCEDURE PageDown;
 BEGIN
  INC (pos, mtTerminal.Lines);
  IF pos >= zeilen THEN pos:= zeilen - mtTerminal.Lines;  END;
  WriteScreen;
  mtAppl.MouseOn;
 END PageDown;    

BEGIN
 CASE action OF
  open:     b:= mtWindows.NewWindow ({MagicAES.NAME, MagicAES.CLOSER,
                 MagicAES.MOVE, MagicAES.VSLIDE, MagicAES.UPARROW,
                 MagicAES.DNARROW, MagicAES.Size, MagicAES.FULL}, 
                 ' Info �ber Magic ', '  ', win2);
            mtWindows.MaxWorkarea (win2, r);
            INC (r.x, 10);  INC (r.y, 10);  DEC (r.w, 20);  DEC (r.h, 20);
            mtWindows.OpenWindow (win2, r);
            term2:= mtTerminal.OpenTerminal (r);
            old:= mtTerminal.ChangeTerminal (term2);
            mtWindows.ConnectTerminal (win2, term2);
            mtTerminal.ClearScreen;
            pos:= 0;  Win2Open:= TRUE;
            |
  close:    mtTerminal.CloseTerminal (term2);
            mtWindows.DeleteWindow (win2);
            Win2Open:= FALSE;  win2:= -1;
            RETURN;
            |
  redraw:   WriteScreen;
            |
  lineup:   LineUp;
            |
  linedown: LineDown;
            |
  pageup:   PageUp;
            |
  pagedown: PageDown;
            |
  ELSE ;
 END;
 mtWindows.WindowSlider (win2, 0, zeilen, mtTerminal.Lines, pos - mtTerminal.Lines);
END ShowInfo;

PROCEDURE ShowDialog (tree, exit, edit: INTEGER);
BEGIN
 dial:= mtRsc.GaddrRsc (Rsc, MagicAES.RTREE, tree);
 b:= mtDials.NewDial (dial);
 mtDials.DialCenter (dial, mtDials.CSCREEN, 0, 0, rect);
 mtDials.DialForm (dial, mtDials.DSTART, small, rect);
 mtDials.DialForm (dial, mtDials.DGROW, small, rect);
 mtDials.DialDraw (dial, 0, 8, scr, FALSE);
 LOOP
  i:= mtDials.DialDo (dial, edit);  b:= mtUtils.DoubleClick (i);
  IF i = exit THEN
   mtUtils.ExclState (dial, exit, MagicAES.SELECTED);
   EXIT;
  END;
 END;
 mtDials.DialForm (dial, mtDials.DSHRINK, small, rect);
 mtDials.DialForm (dial, mtDials.DFINISH, small, rect);
 mtDials.DisposeDial (dial);
END ShowDialog;

PROCEDURE ShowCircle;
CONST   Circle   =   5;  (* Formular/Dialog *)
        Circtext =   5;
        Circbutt =   6;
        Circcolr =   9;
        Circok   =  13;
CONST   Popup2   =   8;  (* Formular/Dialog *)
        Weiss    =   1;  (* STRING in Baum POPUP2 *)
        Schwarz  =   2;  (* STRING in Baum POPUP2 *)
        Rot      =   3;  (* STRING in Baum POPUP2 *)
        Gruen    =   4;  (* STRING in Baum POPUP2 *)
        Blau     =   5;  (* STRING in Baum POPUP2 *)
        Cyan     =   6;  (* STRING in Baum POPUP2 *)
        Gelb     =   7;  (* STRING in Baum POPUP2 *)
        Magenta  =   8;  (* STRING in Baum POPUP2 *)
        Hellgrau =   9;  (* STRING in Baum POPUP2 *)
        Dunkelgr =  10;  (* STRING in Baum POPUP2 *)
        Hellrot  =  11;  (* STRING in Baum POPUP2 *)
        Hellgrun =  12;  (* STRING in Baum POPUP2 *)
        Hellblau =  13;  (* STRING in Baum POPUP2 *)
        Hellcyan =  14;  (* STRING in Baum POPUP2 *)
        Hellgelb =  15;  (* STRING in Baum POPUP2 *)
        Hellmage =  16;  (* STRING in Baum POPUP2 *)

VAR     dial:   mtUtils.tObjcTree;
        pop:    SYSTEM.ADDRESS;
        str:    ARRAY [0..40] OF CHAR;
        index, idx, i, x, y: INTEGER;

 PROCEDURE SetCircle (index: INTEGER);
 VAR i: CARDINAL;
     s: BITSET;
 BEGIN
  IF (index > 0) AND (index <= mtAppl.MaxColors) THEN
   mtUtils.ObjcString (pop, index, str);
   mtUtils.SetObjcString (dial, Circtext, str);
   DEC (index);

   (* Farben setzen *)
   s:= MagicSys.CastToBitset (index);
   FOR i:= 0 TO 3 DO
    IF i IN s THEN INCL (dial^[Circcolr].obSpec.Box.flags, i);
              ELSE EXCL (dial^[Circcolr].obSpec.Box.flags, i);
    END;
   END;

   mtDials.DialDraw (dial, Circtext, 0, scr, FALSE);
   mtDials.DialDraw (dial, Circcolr, 0, scr, FALSE);
  END;
 END SetCircle;

BEGIN
 dial:= mtRsc.GaddrRsc (Rsc, MagicAES.RTREE, Circle);
 pop:= mtRsc.GaddrRsc (Rsc, MagicAES.RTREE, Popup2);
 b:= mtDials.NewDial (dial);  b:= mtDials.NewDial (pop);
 mtDials.SetUserkey (dial, Circbutt, 102, {}, TRUE, TRUE);
 mtDials.SetUserkey (dial, Circtext, 101, {}, TRUE, TRUE);
 index:= Weiss;

 (* Etwas Kosmetik *)
 mtUtils.ObjcString (pop, index, str);
 mtUtils.SetObjcString (dial, Circtext, str);

 mtDials.DialCenter (dial, mtDials.CSCREEN, 0, 0, rect);
 mtDials.DialForm (dial, mtDials.DSTART, small, rect);
 mtDials.DialForm (dial, mtDials.DGROW, small, rect);
 mtDials.DialDraw (dial, 0, 8, rect, FALSE);
 SetCircle (1);

 (* Nichtvorhandene Farben disablen *) 
 FOR i:= (mtAppl.MaxColors + 1) TO Hellmage DO
  mtUtils.InclState (pop, i, MagicAES.DISABLED);
 END;
 
 LOOP
  i:= mtDials.DialDo (dial, -1);  b:= mtUtils.DoubleClick (i);
  CASE i OF
   Circbutt:    INC (index);  IF index > Hellmage THEN index:= Weiss; END;
                WHILE mtUtils.InState (pop, index, MagicAES.DISABLED) DO
                 INC (index);  IF index > Hellmage THEN index:= Weiss; END;
                END;
                SetCircle (index);
                |
   Circtext:    MagicAES.ObjcOffset (dial, Circtext, x, y);
                idx:= mtPopups.TreePopup (pop, x, y, index - 1);
                IF (index >= Weiss) AND (index <= Hellmage) THEN
                 index:= idx;  SetCircle (index);
                END;
                |
   Circok:      mtUtils.ExclState (dial, Circok, MagicAES.SELECTED);
                EXIT;
                | 
   ELSE
  END;
 END;
 mtDials.DialForm (dial, mtDials.DSHRINK, small, rect);
 mtDials.DialForm (dial, mtDials.DFINISH, small, rect);
 mtDials.DisposeDial (dial);
END ShowCircle;

PROCEDURE ShowWinmenu;
VAR str:        ARRAY [0..40] OF CHAR;
    tree:       SYSTEM.ADDRESS;
BEGIN
 tree:= mtRsc.GaddrRsc (Rsc, MagicAES.RTREE, Menuline);
 i:= mtAlerts.Alert (1, '[2][Bitte w„hlen Sie den|Modus der Men�zeile:][[Click|[Drop|[Pull]');
 CASE i OF
  1: mtMenus.ConfigMenu (mtMenus.click);|
  2: mtMenus.ConfigMenu (mtMenus.drop);|
  3: mtMenus.ConfigMenu (mtMenus.pull);|
 END;
 IF WinOpen = FALSE THEN
  IF NOT mtMenus.NewMenu (tree, Menubar) THEN
   i:= mtAlerts.Alert (1, '[3][Men�zeile konnte nicht eingerichtet werden.][[Schade]');
   RETURN
  END;
  IF NOT mtWindows.NewWindow ({0..15}, ' MagicDemo ', ' ', win) THEN
   i:= mtAlerts.Alert (1, '[3][Fenster konnte nicht ge”ffnet werden.][[Schade]');
   RETURN
  END;
  mtWindows.MaxWorkarea (win, rect);
  rect.x:= 100;  rect.y:= 100;
  rect.w:= rect.w DIV 2;  rect.h:= rect.h DIV 2;
  mtWindows.OpenWindow (win, rect);
  term:= mtTerminal.OpenTerminal (rect);
  old:= mtTerminal.ChangeTerminal (term);
  mtWindows.ConnectTerminal (win, term);
  mtMenus.DrawMenu (Menubar, win, bar);
  WinOpen:= TRUE;
 END;
END ShowWinmenu;

PROCEDURE CloseWinmenu;
BEGIN
 IF WinOpen THEN
  mtTerminal.CloseTerminal (term);
  mtWindows.CloseWindow (win);
  mtWindows.DeleteWindow (win);
  mtMenus.FreeMenu (Menubar);
  WinOpen:= FALSE;  win:= -1;
 END;
END CloseWinmenu;

PROCEDURE ShowPopupline;
VAR menu: SYSTEM.ADDRESS;
BEGIN
 menu:= mtRsc.GaddrRsc (Rsc, MagicAES.RTREE, Menuline);
 i:= mtPopups.PopupMenu (menu, ' PopupMenu ');
END ShowPopupline;

PROCEDURE ShowPopups;
CONST Popup2 = 8;  (* Formular/Dialog *)
VAR pop: SYSTEM.ADDRESS;
BEGIN
 MagicStrings.Assign ('  Eintrag 1|  Eintrag 2|  Eintrag 3|  Eintrag 4|  Eintrag 5', string);
 i:= mtPopups.StringPopup (string, ' StringPopup ');
 pop:= mtRsc.GaddrRsc (Rsc, MagicAES.RTREE, Popup2);
 i:= mtPopups.TreePopup (pop, mtAppl.MaxWidth DIV 4, 
                           mtAppl.MaxHeight DIV 4, 1);
END ShowPopups;

PROCEDURE ShowAlerts;
VAR i, j: INTEGER;
BEGIN
 i:= mtAlerts.Alert (1, '[2][Art der Icons:][ [Atari-Like | [Mac-Like ]');
 CASE i OF
  1:   mtAlerts.ConfigAlert (mtAlerts.gemicon);|
  ELSE mtAlerts.ConfigAlert (mtAlerts.alticon);
 END;
 i:= mtAlerts.Alert (2, '[2][Justierung der Buttonkn”pfe:][ [Links | [Mitte | [Rechts ]');
 CASE i OF
  1:   mtAlerts.ConfigAlert (mtAlerts.left);|
  3:   mtAlerts.ConfigAlert (mtAlerts.right);|
  ELSE mtAlerts.ConfigAlert (mtAlerts.center);
 END;
 MagicStrings.Assign (cAlert1, string);
 MagicStrings.Append (cAlert2, string);
 MagicStrings.Append (cAlert3, string);
 MagicStrings.Append (cAlert4, string);
 MagicStrings.Append (cAlert5, string);
 MagicStrings.Append (cAlert6, string);
 MagicStrings.Append (cAlert7, string);
 MagicStrings.Append (cAlert8, string);
 i:= mtAlerts.Alert (1, string);
END ShowAlerts;

PROCEDURE ShowFontsel;
VAR numfont, font, size, width, skew: INTEGER;
    effekt: BITSET;
    select: BOOLEAN;
BEGIN
 IF mtTerminal.TextHandle > 0 THEN
  select:= mtFontselector.FontSelector (mtTerminal.TextHandle, 
        'Fontauswahl (nur Monospaced)', 
            TRUE, TRUE, font, size, width, skew, effekt);
  IF WinOpen THEN
   mtTerminal.UpdateTerminal;
   mtTerminal.ClearScreen;
  END;
 END; (* IF mtTerminal.TextHandle *)
END ShowFontsel;

PROCEDURE RedrawWin (window, x, y, w, h: INTEGER);
VAR rm, rl: mtUtils.tRect;
    c, d: CARDINAL;
    f: INTEGER;
BEGIN
 mtUtils.VarsToRect (x, y, w, h, FALSE, rm);
 f:= 0;
 LOOP
  IF NOT mtWindows.RectList (window, f, rl) THEN  EXIT;  END;  f:= 1;
  IF mtWindows.RcIntersect (rm, rl) THEN
   mtTerminal.ClipRect (TRUE, rl);
   IF window = win THEN
    old:= mtTerminal.ChangeTerminal (term);
    mtTerminal.ClearScreen;
   ELSIF window = win2 THEN
    old:= mtTerminal.ChangeTerminal (term2);
    mtTerminal.ClearScreen;
    ShowInfo (redraw);
   END;
  END;
 END;
 mtTerminal.ClipRect (FALSE, rl);
END RedrawWin;


VAR     mesag:          ARRAY [0..7] OF INTEGER;
        taste, scan, clicks, f, title, item, x, y: INTEGER;
        event, button, kbshift, scraps: BITSET;
        ascii:          CHAR;
        xx, yy:         CARDINAL;
        keybrd, ExitProgram: BOOLEAN;
        menu:           SYSTEM.ADDRESS;

PROCEDURE DoMenu (title, item: INTEGER);
BEGIN
 ExitProgram:= FALSE;
 CASE item OF
  Info:     ShowInfo (open);|
  Quit:     ExitProgram:= TRUE;|
  Moveobjc: ShowDialog (Mover, Moverok, -1);|
  Stringob: ShowDialog (String, Stringok,-1);|
  Buttonob: ShowDialog (Buttons1, Butt1ok, -1);
            ShowDialog (Buttons2, Butt2ok, -1);|
  Frameobj: ShowDialog (Frame, Frameok, -1);|
  Circleob: ShowCircle;|
  Editobjc: ShowDialog (Edit, Editok, Editable);|
  Winmenu : ShowWinmenu;|
  Popupmen: ShowPopupline;|
  Popups  : ShowPopups;|
  Alertbox: ShowAlerts;|
  Fontsel : ShowFontsel;|
  ELSE ;
 END;
 MagicAES.MenuTnormal (menu, title, 1);
END DoMenu;

PROCEDURE DoKeyboard (scan: INTEGER; kbshift: BITSET);
VAR title, item, mess: INTEGER;
BEGIN
 IF mtUtils.ScanMenu (menu, scan, kbshift, title, item) THEN
  mesag[0]:= MagicAES.MNSELECTED;
  mesag[1]:= mtAppl.ApplIdent;
  mesag[2]:= 0;
  mesag[3]:= title;
  mesag[4]:= item;
  INCL (event, MagicAES.MUMESAG);  
 ELSIF scan = 98 THEN
  ShowInfo (open);
 END;
END DoKeyboard;

BEGIN
 mtAlerts.ConfigAlert (mtAlerts.right);
 mtAlerts.ConfigAlert (mtAlerts.alticon);
 
 (* Bild zu klein? *)
 IF mtAppl.MaxWidth < 639 THEN 
  MagicStrings.Assign (cRes1, string);
  MagicStrings.Append (cRes2, string);
  i:= mtAlerts.Alert (1, string);
 
 ELSE (* Bild passt *)
  scr.x:= 0;  scr.y:= 0; scr.w:= mtAppl.MaxWidth;  scr.h:= mtAppl.MaxHeight;
  small.x:= mtAppl.MaxWidth DIV 2;  small.y:= mtAppl.MaxHeight DIV 2;
  small.w:= 2;  small.h:= 2;  WinOpen:= FALSE;
  IF mtRsc.LoadRsc ('MAGIC.RSC', Rsc) THEN
   i:= mtFonts.LoadFonts (mtTerminal.TextHandle);
   MagicStrings.Assign ('MAGIC.INF', string);
   MagicAES.ShelFind (string);
   b:= mtText.NewTEXT (Text);
   i:= mtText.ReadText (Text, string);
   zeilen:= SHORT (mtText.GetNumber (Text));
   IF i = 0 THEN

    menu:= mtRsc.GaddrRsc (Rsc, MagicAES.RTREE, Mainmenu);
    b:= mtAESMenus.InitMenuline (menu);
    mtAESMenus.DrawMenuline (menu);
    MagicStrings.Assign (cTitle, string);
    MagicStrings.Append (cTitle2, string);
    i:= mtAlerts.Alert (1, string);

    LOOP (* Mal sehen was so passiert *)
     mtAppl.MouseArrow;

     event:= MagicAES.EvntMulti 
         ({MagicAES.MUMESAG, MagicAES.MUKEYBD, MagicAES.MUM1},
          0, {}, {}, 0, bar, 0, rect, mesag, 0, 0, x, y,
          button, taste, kbshift, scan, ascii, clicks);

     IF MagicAES.MUKEYBD IN event THEN  DoKeyboard (scan, kbshift);  END;

     IF MagicAES.MUMESAG IN event THEN
      CASE mesag[0] OF
       MagicAES.MNSELECTED: DoMenu (mesag[3], mesag[4]);
                            |
       MagicAES.WMREDRAW:   RedrawWin (mesag[3], mesag[4], mesag[5], 
                                       mesag[6], mesag[7]);
                            mtAppl.MouseOn;
                            |
       MagicAES.WMTOPPED:   mtWindows.WindowTop (mesag[3]);
                            IF mesag[3] = win THEN
                             mtMenus.DrawMenu (Menubar, win, bar);
                             old:= mtTerminal.ChangeTerminal (term);
                             mtAppl.MouseOn;
                            ELSIF mesag[3] = win2 THEN
                             old:= mtTerminal.ChangeTerminal (term2);
                             ShowInfo (redraw);
                            END;
                            |
       MagicAES.WMCLOSED:   IF mesag[3] = win THEN
                             CloseWinmenu;
                            ELSIF mesag[3] = win2 THEN
                             ShowInfo (close);
                            ELSE
                             mtWindows.CloseWindow (mesag[3]);
                            END;
                            |
       MagicAES.WMFULLED:   mtWindows.WindowFulled (mesag[3]);
                            IF mesag[3] = win THEN
                             mtMenus.DrawMenu (Menubar, win, bar);
                             mtTerminal.ClearScreen; 
                             mtAppl.MouseOn;
                            END;
                            |
       MagicAES.WMSIZED:    mtWindows.WindowSize (mesag[3], mesag[6], mesag[7]);
                            IF mesag[3] = win THEN
                             mtMenus.DrawMenu (Menubar, win, bar);
                             mtTerminal.ClearScreen; 
                             mtAppl.MouseOn;
                            END;
                            |
       MagicAES.WMMOVED:    mtWindows.WindowPos (mesag[3], mesag[4], mesag[5]);
                            IF mesag[3] = win THEN
                             mtMenus.DrawMenu (Menubar, win, bar);
                             mtAppl.MouseOn;
                            END;
                            |
       MagicAES.WMARROWED:  IF win2 = mesag[3] THEN
                             CASE mesag[4] OF
                              MagicAES.WAUPPAGE: ShowInfo (pageup);|
                              MagicAES.WADNPAGE: ShowInfo (pagedown);|
                              MagicAES.WAUPLINE: ShowInfo (lineup);|
                              MagicAES.WADNLINE: ShowInfo (linedown);|
                              ELSE ;
                             END;
                            END;
                            |
        ELSE ;
      END; (* CASE *)
     END; (* IF MagicAES.MUMESAG *)
      
     IF MagicAES.MUM1 IN event THEN
      IF win = mtWindows.TopWindow() THEN
       mtMenus.HandleMenu (title, item);
       IF title > 0 THEN
        mtTerminal.WriteConst ('Objektnummer Men�:    ');
        mtTerminal.WriteInt (title, 0);  mtTerminal.WriteLn;
        mtTerminal.WriteConst ('Objektnummer Eintrag: ');
        mtTerminal.WriteInt (item, 0);
        (* mtTerminal.WriteConst (' -> ');
        mtTerminal.WriteLine (tree^[entry].obSpec.StringPtr^); *)
        mtTerminal.WriteLn;
        mtAppl.MouseOn;
       END;
      END;
     END;
 
     IF ExitProgram THEN
      i:= mtAlerts.Alert (1, '[2][|%FWirklich beenden?][[Ja|[Nein]');
      IF i = 1 THEN  EXIT;  END;
     END;
 
    END; (* LOOP *)

   ELSE
    i:= mtAlerts.Alert (1, '[3][|%FInfo-Text konnte nicht gelesen werden!][ [Hoppla! ]');
   END; (* IF i > 0 THEN *)
  ELSE (* Resource nicht gefunden *)
   i:= mtAlerts.Alert (1, '[3][|%FResource nicht gefunden!][ [Hoppla! ]');
  END;
 END;
 mtFonts.UnloadFonts (mtTerminal.TextHandle);
 mtAppl.ApplTerm (0);
END Magic.
